package com.tianyuchan.exception.contract.controller;

import com.tianyuchan.exception.contract.ContractManage;
import com.tianyuchan.exception.dto.resp.BaseResponse;
import com.tianyuchan.exception.dto.req.ContractManageReq;
import com.tianyuchan.exception.util.ResponseProcessor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;


/**
 * @Classname : ContractManageController
 * @Description : 合同管理控制器
 * @Author : cty
 * @Date 2023/3/19 22:40
 */

@RestController
@RequestMapping("bestPractice/exception/contractManage")
public class ContractManageController {

    @Resource
    private ContractManage contractManage;

    /**
     * 创建合同
     * @param contractManageReq
     * @return
     */
    @PostMapping("/createContract")
    public BaseResponse<String> createContract(@RequestBody ContractManageReq contractManageReq) {
        return ResponseProcessor.handle(
                contractManageReq,
                BaseResponse.success(),
                "createContract",
                req -> BaseResponse.success(contractManage.createContract(req)));
    }

    /**
     * 合同付款
     * @param contractManageReq
     * @return
     */
    @PostMapping("/payContract")
    public BaseResponse<String> payContract(@RequestBody ContractManageReq contractManageReq) {
        try {

        } finally {
            System.out.println();
        }

        return ResponseProcessor.handle(
                contractManageReq,
                BaseResponse.success(),
                "payContract",
                req -> BaseResponse.success(contractManage.payContract(req)));
    }

}
